<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class customer extends CI_Controller {
	  var $data = array();

	  public function __construct() {
        parent::__construct();
        if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
        $this->data['sidebarhome']="";
	    $this->data['sidebardaftar']="";
	    $this->data['sidebardaftarclient']="";
	    $this->data['sidebardaftarfinance']="";
    	$this->data['sidebarinputdata']="";
    	
    	$this->data['sidebarcustomer']="";
    	$this->data['sidebarcabang']="";
    	$this->data['sidebaruser']="";

    	$this->load->model('mkaryawan');

       }

    public function index() {
       $this->data['sidebarcustomer']="active";
       $this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       $this->load->view('vlistcustomer',$this->data);
    }

    public function tambahcustomer() {
       $this->load->view('vtambahcustomer',$this->data);    	
    }

    public function Ftambahcustomer() {
        $data123 = array(
			'nama_customer' => $this->input->post('nama_customer'),            
			'keterangan' => $this->input->post('keterangan'),            
		);
		$this->mkaryawan->mtambahcustomer($data123);
        redirect('customer/tambahcustomer/y');    
    }
    public function editcustomer() {
    	$id=$this->uri->segment(3);
    	$this->data['query'] = $this->mkaryawan->mgetdatacustomer($id);
		$this->load->view('veditcustomer',$this->data); 
	}	
	
    public function updatecustomer() {
        $data123 = array(
			'id_customer' => $this->input->post('id_customer'),
			'nama_customer' => $this->input->post('nama_customer'),
			'keterangan' => $this->input->post('keterangan'),
		);
		$this->mkaryawan->mupdatecustomer($data123);		
	}	
}
